tests: Modernize valgrind infrastructure
authorColin Walters <walters@verbum.org>
Wed, 11 May 2016 19:54:48 +0000 (15:54 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 9 Jun 2016 21:10:35 +0000 (21:10 +0000)
The recent memleak fixes motivated me to look at the bitrotted code to
run invocations of `ostree` in the test suite underneath valgrind.

There are a few things here.  First, update suppressions file from
libhif, since I recently worked on it.

When running *uninstalled* as we now support, we need
`libtool --mode=execute` in the mix so it expands out to
the uninstalled binary and we don't valgrind the intermediate shell.

However, it's harder than that because we chdir into a tmpdir,
which defeats the libtool logic.  AFAICS, the only fix for this
is to determine the realbin path before we chdir, and then unfortunately
we need to change every use of `ostree` to `${OSTREE}` =(

Then this immediately breaks for me on RHEL7 because my ancient
copy of `valgrind-3.10.0-16.el7.x86_64` is unaware of syscall 306, i.e.
`syncfs`.

But let's do this first before I dive into that.

Closes: #292
Approved by: krnowak

Makefile-tests.am
src/libostree/ostree-repo-commit.c
tests/glib.supp [new file with mode: 0644]
tests/libtest.sh
tests/ostree-valgrind.supp [deleted file]
tests/ostree.supp [new file with mode: 0644]

index 58397d37b022138cf328e62ffd305f6c9cb8043a..50c01273dda2cbfdacb8e20a1252aeb877cbd018 100644 (file)
@@ -25,9 +25,11 @@ include $(top_srcdir)/buildutil/glib-tap.mk
 TESTS_ENVIRONMENT += OT_TESTS_DEBUG=1 \
        GI_TYPELIB_PATH=$$(cd $(top_builddir) && pwd) \
        LD_LIBRARY_PATH=$$(cd $(top_builddir)/.libs && pwd) \
-       PATH=$$(cd $(top_builddir) && pwd):$${PATH} \
+       PATH=$$(cd $(top_builddir)/tests && pwd):$${PATH} \
        $(NULL)
 
+uninstalled_test_data = tests/ostree-symlink-stamp
+
 uninstalled_test_scripts = tests/test-symbols.sh
 
 test_scripts = \
@@ -231,7 +233,12 @@ EXTRA_DIST += \
 tests/libreaddir-rand.so: Makefile
        $(AM_V_GEN) ln -fns ../.libs/libreaddir-rand.so tests
 ALL_LOCAL_RULES += tests/libreaddir-rand.so
-CLEANFILES += tests/libreaddir-rand.so
+CLEANFILES += tests/libreaddir-rand.so tests/ostree-symlink-stamp tests/ostree
+
+tests/ostree-symlink-stamp:
+       @real_bin=`cd $(top_builddir) && libtool --mode=execute echo ostree`; \
+       ln -sf "$${real_bin}" tests/ostree; \
+       touch $@
 
 # Unfortunately the glib test data APIs don't actually handle
 # non-recursive Automake, so we change our code to canonically look
index fc6ffd24937172090daa079c4d800b11e0e5e5b6..685eadd0f9de1b7706134b5e7774f67bc762b12f 100644 (file)
@@ -1472,7 +1472,7 @@ ostree_repo_commit_transaction (OstreeRepo                  *self,
   /* FIXME: Added since valgrind in el7 doesn't know about
    * `syncfs`...we should delete this later.
    */
-  if (g_getenv ("OSTREE_SUPRESS_SYNCFS") == NULL)
+  if (g_getenv ("OSTREE_SUPPRESS_SYNCFS") == NULL)
     {
       if (syncfs (self->tmp_dir_fd) < 0)
         {
diff --git a/tests/glib.supp b/tests/glib.supp
new file mode 100644 (file)
index 0000000..3344907
--- /dev/null
@@ -0,0 +1,535 @@
+# This GLib suppressions file is known to be used at least by:
+#
+#  - rpm-software-management/libhif
+#
+# Please use the upstream verison in libhif for changes.
+{
+   gobject_init_1
+   Memcheck:Leak
+   ...
+   fun:gobject_init
+}
+{
+   g_type_register_static_1
+   Memcheck:Leak
+   ...
+   fun:g_type_register_static
+}
+{
+   g_type_register_fundamental
+   Memcheck:Leak
+   ...
+   fun:g_type_register_fundamental
+}
+{
+   g_type_init_with_debug_flags
+   Memcheck:Leak
+   ...
+   fun:g_type_init_with_debug_flags
+}
+{
+   g_type_class_ref_1
+   Memcheck:Leak
+   ...
+   fun:type_iface_vtable_base_init_Wm
+   ...
+   fun:g_type_class_ref
+}
+{
+   g_type_class_ref_2
+   Memcheck:Leak
+   ...
+   fun:type_class_init_Wm
+   ...
+   fun:g_type_class_ref
+}
+{
+   g_type_add_interface_static
+   Memcheck:Leak
+   ...
+   fun:g_type_add_interface_static
+}
+{
+   g_param_spec_internal
+   Memcheck:Leak
+   ...
+   fun:g_type_class_ref
+   fun:g_type_create_instance
+   fun:g_param_spec_internal
+}
+{
+   g_param_spec_enum
+   Memcheck:Leak
+   ...
+   fun:g_type_class_ref
+   fun:g_param_spec_enum
+}
+{
+   g_param_spec_flags
+   Memcheck:Leak
+   ...
+   fun:g_type_class_ref
+   fun:g_param_spec_flags
+}
+{
+   g_quark_from_static_string
+   Memcheck:Leak
+   ...
+   fun:g_quark_from_static_string
+}
+{
+   g_quark_from_string
+   Memcheck:Leak
+   ...
+   fun:g_quark_from_string
+}
+{
+   g_value_register_transform_func
+   Memcheck:Leak
+   ...
+   fun:g_value_register_transform_func
+}
+{
+   test_run_seed
+   Memcheck:Leak
+   ...
+   fun:g_rand_new_with_seed_array
+   fun:test_run_seed
+   ...
+   fun:g_test_run_suite
+}
+{
+   g_test_init
+   Memcheck:Leak
+   ...
+   fun:g_rand_new_with_seed_array
+   ...
+   fun:g_test_init
+}
+{
+   g_intern_static_string
+   Memcheck:Leak
+   ...
+   fun:g_intern_static_string
+}
+{
+   g_main_context_push_thread_default
+   Memcheck:Leak
+   ...
+   fun:g_queue_new
+   fun:g_main_context_push_thread_default
+}
+{
+   g_main_context_push_thread_default_inlined
+   Memcheck:Leak
+   ...
+   fun:g_slice_alloc0
+   fun:g_main_context_push_thread_default
+}
+{
+   g_dbus_error_register_error
+   Memcheck:Leak
+   ...
+   fun:g_dbus_error_register_error
+}
+{
+   g_param_spec_pool_insert
+   Memcheck:Leak
+   ...
+   fun:g_param_spec_pool_insert
+}
+{
+   g_main_context_default
+   Memcheck:Leak
+   ...
+   fun:g_main_context_default
+}
+{
+   g_main_context_check
+   Memcheck:Leak
+   ...
+   fun:g_ptr_array_add
+   fun:g_main_context_check
+}
+{
+   g_test_run_suite
+   Memcheck:Leak
+   ...
+   fun:g_slist_copy
+   fun:g_test_run_suite_internal
+   fun:g_test_run_suite
+}
+{
+   g_dbus_interface_info_cache_build
+   Memcheck:Leak
+   ...
+   fun:g_dbus_interface_info_cache_build
+}
+{
+   g_cancellable_push_current
+   Memcheck:Leak
+   ...
+   fun:thread_memory_from_self
+   ...
+   fun:g_cancellable_push_current
+}
+{
+   _g_io_module_get_default
+   Memcheck:Leak
+   ...
+   fun:g_io_module_new
+   fun:g_io_modules_scan_all_in_directory_with_scope
+   fun:_g_io_modules_ensure_loaded
+   fun:_g_io_module_get_default
+}
+{
+   g_io_scheduler_push_job
+   Memcheck:Leak
+   ...
+   fun:init_scheduler
+   fun:g_once_impl
+   fun:g_io_scheduler_push_job
+}
+{
+   g_io_scheduler_push_job_2
+   Memcheck:Leak
+   ...
+   fun:g_system_thread_new
+   ...
+   fun:g_io_scheduler_push_job
+}
+{
+   g_bus_get_sync__available_connections
+   Memcheck:Leak
+   ...
+   fun:g_hash_table_new
+   fun:initable_init
+   fun:g_initable_init
+   fun:g_bus_get_sync
+}
+{
+   g_socket_connection_factory_register_type
+   Memcheck:Leak
+   ...
+   fun:g_socket_connection_factory_register_type
+}
+{
+   g_test_add_vtable
+   Memcheck:Leak
+   ...
+   fun:g_test_add_vtable
+}
+{
+   g_mutex_lock
+   Memcheck:Leak
+   ...
+   fun:g_mutex_impl_new
+   fun:g_mutex_get_impl
+   fun:g_mutex_lock
+}
+{
+   g_thread_self
+   Memcheck:Leak
+   ...
+   fun:g_thread_self
+}
+{
+   g_rec_mutex_lock
+   Memcheck:Leak
+   ...
+   fun:g_rec_mutex_impl_new
+   fun:g_rec_mutex_get_impl
+   fun:g_rec_mutex_lock
+}
+{
+   test_case_run
+   Memcheck:Leak
+   ...
+   fun:g_malloc0
+   fun:test_case_run
+   ...
+   fun:g_test_run_suite
+}
+{
+   g_get_charset
+   Memcheck:Leak
+   ...
+   fun:g_get_charset
+}
+{
+   g_test_run_suite__timer_new
+   Memcheck:Leak
+   ...
+   fun:g_timer_new
+   fun:test_case_run
+   ...
+   fun:g_test_run_suite
+}
+{
+   g_test_run_suite__timer_new2
+   Memcheck:Leak
+   ...
+   fun:g_timer_new
+   fun:test_case_run_suite_internal
+   ...
+   fun:g_test_run_suite
+}
+{
+   g_test_run_suite__strconcat
+   Memcheck:Leak
+   ...
+   fun:g_strconcat
+   fun:test_case_run
+   ...
+   fun:g_test_run_suite
+   fun:g_test_run
+}
+{
+   g_type_interface_add_prerequisite
+   Memcheck:Leak
+   ...
+   fun:g_type_interface_add_prerequisite
+}
+{
+   <insert_a_suppression_name_here>
+   Memcheck:Leak
+   ...
+   fun:g_slist_copy
+   fun:g_test_run_suite_internal
+   ...
+   fun:g_test_run_suite
+}
+{
+   g_set_prgname
+   Memcheck:Leak
+   ...
+   fun:g_set_prgname
+}
+{
+   g_test_run_suite__strconcat_2
+   Memcheck:Leak
+   ...
+   fun:g_strconcat
+   fun:g_test_run_suite_internal
+}
+{
+   g_test_run_suite__strdup
+   Memcheck:Leak
+   ...
+   fun:g_strdup
+   fun:g_test_run_suite_internal
+}
+{
+   g_private_get
+   Memcheck:Leak
+   ...
+   fun:g_private_get
+}
+{
+   g_private_set
+   Memcheck:Leak
+   ...
+   fun:g_private_set
+}
+{
+   g_static_mutex_get_mutex_impl
+   Memcheck:Leak
+   ...
+   fun:g_static_mutex_get_mutex_impl
+}
+{
+   g_variant_type_info_unref
+   Memcheck:Leak
+   ...
+   fun:g_hash_table_remove
+   fun:g_variant_type_info_unref
+}
+{
+   g_rw_lock_reader_lock
+   Memcheck:Leak
+   ...
+   fun:g_rw_lock_impl_new
+   fun:g_rw_lock_get_impl
+   fun:g_rw_lock_reader_lock
+}
+{
+   g_child_watch_finalize__rt_sigaction
+   Memcheck:Param
+   rt_sigaction(act->sa_flags)
+   fun:__libc_sigaction
+   ...
+   fun:g_child_watch_finalize
+}
+{
+   g_dbus_worker_new
+   Memcheck:Leak
+   fun:calloc
+   ...
+   fun:_g_dbus_worker_new
+}
+{
+   gdbus_shared_thread_func
+   Memcheck:Leak
+   match-leak-kinds: definite
+   ...
+   fun:g_malloc
+   ...
+   fun:gdbus_shared_thread_func
+}
+{
+   g_task_start_task_thread
+   Memcheck:Leak
+   match-leak-kinds: definite
+   fun:malloc
+   fun:g_malloc
+   fun:g_slice_alloc
+   fun:g_slice_alloc0
+   ...
+   fun:g_thread_pool_push
+   fun:g_task_start_task_thread
+}
+{
+   g_get_language_names
+   Memcheck:Leak
+   match-leak-kinds: definite
+   fun:calloc
+   fun:g_malloc0
+   fun:g_get_language_names
+}
+{
+   g_get_filename_charsets
+   Memcheck:Leak
+   match-leak-kinds: definite
+   ...
+   fun:g_get_filename_charsets
+   fun:g_filename_display_name
+}
+{
+   g_main_current_source
+   Memcheck:Leak
+   match-leak-kinds: definite
+   fun:malloc
+   fun:g_malloc
+   ...
+   fun:g_main_current_source
+   fun:g_task_return
+   fun:g_task_thread_pool_thread
+}
+{
+   g_once_init_enter
+   Memcheck:Leak
+   match-leak-kinds: definite
+   ...
+   fun:g_once_init_enter
+}
+{
+   g_child_watch_source_new
+   Memcheck:Leak
+   match-leak-kinds: definite
+   ...
+   fun:g_thread_new
+   ...
+   fun:g_child_watch_source_new
+}
+{
+   continue_writing_in_idle_cb
+   Memcheck:Leak
+   match-leak-kinds: definite
+   ...
+   fun:g_task_new
+   ...
+   fun:continue_writing_in_idle_cb
+   fun:g_main_context_dispatch
+}
+{
+   g_main_current_source
+   Memcheck:Leak
+   match-leak-kinds: definite
+   fun:malloc
+   ...
+   fun:g_main_current_source
+}
+{
+   g_thread_pool_push
+   Memcheck:Leak
+   match-leak-kinds: definite
+   fun:malloc
+   ...
+   fun:g_thread_pool_push
+}
+{
+   leak_test_dbus_dispose
+   Memcheck:Leak
+   match-leak-kinds: definite
+   fun:malloc
+   ...
+   fun:g_main_loop_run
+   fun:g_test_dbus_down
+}
+{
+   leak_test_dbus_down
+   Memcheck:Leak
+   match-leak-kinds: definite
+   fun:calloc
+   fun:g_malloc0
+   fun:g_main_loop_new
+   fun:g_test_dbus_down
+}
+{
+   leak_socket_client_connect
+   Memcheck:Leak
+   match-leak-kinds: definite
+   fun:malloc
+   fun:g_malloc
+   fun:g_slice_alloc
+   fun:g_slice_alloc0
+   fun:g_socket_client_connect_async
+   fun:g_socket_client_connect_to_uri_async
+}
+{
+   leak_signal_handlers_disconnect_matched
+   Memcheck:Leak
+   match-leak-kinds: definite
+   fun:calloc
+   fun:g_malloc0
+   ...
+   fun:g_slice_alloc
+   ...
+   fun:g_signal_handlers_disconnect_matched
+}
+{
+   g_tls_connection_gnutls_init_priorities
+   Memcheck:Leak
+   match-leak-kinds: definite
+   fun:malloc
+   fun:g_malloc
+   fun:g_strdup
+   fun:g_tls_connection_gnutls_init_priorities
+}
+{
+   g_tls_connection_gnutls_heisenbug_likely_same_as_above
+   Memcheck:Leak
+   match-leak-kinds: definite
+   fun:malloc
+   fun:g_malloc
+   fun:g_strdup
+   ...
+   fun:g_tls_client_connection_new
+}
+{
+   g_unix_signal_add_full
+   Memcheck:Leak
+   match-leak-kinds: definite
+   fun:malloc
+   fun:g_malloc
+   ...
+   fun:g_thread_new
+   ...
+   fun:g_unix_signal_add_full
+}
+{
+   glib_worker_1
+   Memcheck:Leak
+   ...
+   fun:glib_worker_main
+}
index 34976e23cb8d8cd14ee28e19e818543dd32ad5b3..2916bdbb58684362a2917fc139c4651dd2d18030 100755 (executable)
@@ -77,7 +77,7 @@ if test -n "${OT_TESTS_DEBUG:-}"; then
 fi
 
 if test -n "${OT_TESTS_VALGRIND:-}"; then
-    CMD_PREFIX="env G_SLICE=always-malloc valgrind -q --leak-check=full --num-callers=30 --suppressions=${test_srcdir}/ostree-valgrind.supp"
+    CMD_PREFIX="env G_SLICE=always-malloc OSTREE_SUPPRESS_SYNCFS=1 valgrind -q --leak-check=full --num-callers=30 --suppressions=${test_srcdir}/glib.supp --suppressions=${test_srcdir}/ostree.supp"
 else
     CMD_PREFIX="env LD_PRELOAD=${test_builddir}/libreaddir-rand.so"
 fi
diff --git a/tests/ostree-valgrind.supp b/tests/ostree-valgrind.supp
deleted file mode 100644 (file)
index 00efd87..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-{
-   g_type_init_with_debug_flags calloc
-   Memcheck:Leak
-   fun:calloc
-   ...
-   fun:g_type_init_with_debug_flags
-   ...
-}
-
-{
-  g_type_add_interface_static malloc
-  Memcheck:Leak
-  fun:malloc
-  ...
-  fun:g_type_add_interface_static
-  ...
-}
-
-{
-  g_type_add_interface_dynamic malloc
-  Memcheck:Leak
-  fun:malloc
-  ...
-  fun:g_type_add_interface_dynamic
-  ...
-}
-
-{
-  g_type_class_ref malloc
-  Memcheck:Leak
-  fun:malloc
-  ...
-  fun:g_type_class_ref
-  ...
-}
-
-{
-  g_type_register_dynamic malloc
-  Memcheck:Leak
-  fun:malloc
-  ...
-  fun:g_type_register_dynamic
-  ...
-}
-
-{
-   g_type_init_with_debug_flags malloc
-   Memcheck:Leak
-   fun:malloc
-   ...
-   fun:g_type_init_with_debug_flags
-   ...
-}
-
-{
-   g_type_init_with_debug_flags realloc
-   Memcheck:Leak
-   fun:realloc
-   ...
-   fun:g_type_init_with_debug_flags
-   ...
-}
-
-{
-   g_test_add_vtable malloc
-   Memcheck:Leak
-   fun:malloc
-   ...
-   fun:g_test_add_vtable
-   ...
-}
-
-{
-   g_test_init
-   Memcheck:Leak
-   fun:malloc
-   ...
-   fun:g_test_init
-   ...
-}
-
-{
-   g_type_register_static malloc
-   Memcheck:Leak
-   fun:malloc
-   ...
-   fun:g_type_register_static
-   ...
-}
-
-{
-   g_type_register_static realloc
-   Memcheck:Leak
-   fun:realloc
-   ...
-   fun:g_type_register_static
-   ...
-}
-
-{
-   g_type_register_fundamental never freed
-   Memcheck:Leak
-   fun:malloc
-   ...
-   fun:g_type_register_fundamental
-   ...
-}
-
-{
-   g_type_class_ref never finalized
-   Memcheck:Leak
-   fun:calloc
-   ...
-   fun:g_type_class_ref
-   ...
-}
-
-{
-   DBusGValue qdata
-   Memcheck:Leak
-   fun:realloc
-   fun:g_realloc
-   fun:g_type_set_qdata
-   fun:_dbus_g_value_types_init
-   ...
-}
-
-{
-   gettext conditional jump
-   Memcheck:Cond
-   fun:__GI___strcasecmp_l
-   fun:__gconv_open
-   fun:_nl_find_msg
-   fun:__dcigettext
-   ...
-}
-
-{
-   gettext uninitialized value
-   Memcheck:Value8
-   fun:__GI___strcasecmp_l
-   fun:__gconv_open
-   fun:_nl_find_msg
-   fun:__dcigettext
-   ...
-}
-
-{
-   font config invalid reads
-   Memcheck:Addr4
-   ...
-   fun:FcConfigParseAndLoad
-   ...
-}
-
-{
-   dynamic loader conditional jump
-   Memcheck:Cond
-   fun:index
-   fun:expand_dynamic_string_token
-   fun:_dl_map_object
-   fun:map_doit
-   fun:_dl_catch_error
-   fun:do_preload
-   fun:dl_main
-   ...
-}
-
-{
-   g_vfs_get_local
-   Memcheck:Leak
-   ...
-   fun:g_vfs_get_local
-   ...
-}
-
-{
-   _g_io_modules_ensure_loaded
-   Memcheck:Leak
-   ...
-   fun:_g_io_modules_ensure_loaded
-   ...
-}
-
-{
-   _g_io_module_get_default
-   Memcheck:Leak
-   ...
-   fun:_g_io_module_get_default
-   ...
-}
-
-{
-   _dl_allocate_tls
-   Memcheck:Leak
-   ...
-   fun:_dl_allocate_tls
-   ...
-}
diff --git a/tests/ostree.supp b/tests/ostree.supp
new file mode 100644 (file)
index 0000000..b81ea51
--- /dev/null
@@ -0,0 +1 @@
+# Use this to suppress "possibly lost" for global statics